package com.h.mybatis.controller;


import com.h.mybatis.model.UserInfo;
import com.h.mybatis.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RequestMapping("/user")
@RestController
public class UserInfoController {
    // 第二种测试接口的方式

    @Autowired
    private UserInfoService userInfoService;

    @RequestMapping("/getAllUser")
    public List<UserInfo> getAllUser() {
        return userInfoService.getAllUser();
    }

    @RequestMapping("/getAllById")
    public UserInfo getAllById(Integer id) {
        return userInfoService.getAllById(id);
    }

    @RequestMapping("/getXMLLAllById")
    public List<UserInfo> getXMLAllById(Integer id) {
        return userInfoService.getXMLAllById(id);
    }

    @RequestMapping("/login")
    public boolean login(String username,String password) {
        UserInfo userInfo = userInfoService.queryUserByUserNameAndPassword(username, password);
        return userInfo == null ? false : true;
    }
}
